import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '司机姓名',
    align: 'center',
    dataIndex: 'name',
  },
  {
    title: '联系电话',
    align: 'center',
    dataIndex: 'phone',
  },
  {
    title: '车牌号',
    align: 'center',
    dataIndex: 'vehicleNo',
  },
  {
    title: '备注',
    align: 'center',
    dataIndex: 'remarks',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '司机姓名',
    field: 'name',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '联系电话',
    field: 'phone',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '车牌号',
    field: 'vehicleNo',
    component: 'JInput',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '司机姓名',
    field: 'name',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入司机姓名!' }];
    },
  },
  {
    label: '联系电话',
    field: 'phone',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入联系电话!' },
        { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!' },
      ];
    },
  },
  {
    label: '车牌号',
    field: 'vehicleNo',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: false },
        {
          pattern:
            '^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z](?:[A-HJ-NP-Z0-9]{5}|[A-HJ-NP-Z0-9]{4}[挂学警港澳])|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][DF][A-HJ-NP-Z0-9]{5})$',
          message: '不符合校验规则!',
        },
      ];
    },
  },
  {
    label: '备注',
    field: 'remarks',
    component: 'InputTextArea',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: { title: '司机姓名', order: 0, view: 'text', type: 'string' },
  phone: { title: '联系电话', order: 1, view: 'text', type: 'string' },
  vehicleNo: { title: '车牌号', order: 2, view: 'text', type: 'string' },
  remarks: { title: '备注', order: 3, view: 'textarea', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
